package com.siyuanren.gcocp.common.enums;

import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * Created by   guwr
 * Project_name gcocp-parent
 * Path         com.siyuanren.gcocp.enums.AdvisoryEnum
 * Date         2017/4/26
 * Time         17:19
 * Description
 */
public enum AdvisoryEnum {
    IMAGE_TEXT("图文", 0),
    VOICE("语音", 1);
    private String desc;
    private int value;

    AdvisoryEnum(String desc, int value) {
        this.desc = desc;
        this.value = value;
    }

    public static AdvisoryEnum getModel(int value) {
        for (AdvisoryEnum he : AdvisoryEnum.values()) {
            if (Objects.equals(value, he.getValue())) {
                return he;
            }
        }
        return null;
    }

    public static String getEnumDesc(Integer value) {
        if (value == null) {
            return StringUtils.EMPTY;
        }
        AdvisoryEnum model = getModel(value);
        if (model == null) {
            return StringUtils.EMPTY;
        }
        return model.getDesc();
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }
}